package cn.xu.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ValidateUserNameServlet extends HttpServlet {


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		/*
		 * 如果登陆的用户名中有admin 则表示已经注册过了
		 */
		String username = request.getParameter("username");
		if(username.contains("admin")){
			response.getWriter().print("1");
		}else if(username.trim().isEmpty()){
			response.getWriter().print("2");
		}else{
			response.getWriter().print("3");
			
		}

	}

}
